package com.yyfax.pay.third.model.to.fuioudeposit.xml;

import java.io.StringWriter;
import java.util.List;

import com.alibaba.fastjson.annotation.JSONField;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.StaxWriter;

/**
 * @author yejc
 * @date 2017-09-08
 * @since v1.0.0
 */
@XStreamAlias("plain")
public class ChargeWithdrawPlain {
	@JSONField(serialize = false)
	@XStreamAlias("resp_code")
	private String respCode;

	@JSONField(serialize = false)
	@XStreamAlias("mchnt_cd")
	private String merchantId;

	@JSONField(serialize = false)
	@XStreamAlias("mchnt_txn_ssn")
	private String serailNo;

	@JSONField(serialize = false)
	@XStreamAlias("busi_tp")
	private String busiType;

	@XStreamAlias("total_number")
	private Integer totalNumber;

	@XStreamAlias("results")
	private List<ChargeWithdrawPlain.ChargeWithdrawResult> results;

	public String toXml() {
		QNameMap qmap = new QNameMap();
		qmap.setDefaultPrefix("");
		StaxDriver staxDriver = new StaxDriver(qmap);
		XStream xstream = new XStream(staxDriver);
		xstream.autodetectAnnotations(true);
		xstream.ignoreUnknownElements();
		xstream.alias("plain", this.getClass());
		try {
			StringWriter strWriter = new StringWriter();
			StaxWriter sw = new StaxWriter(staxDriver.getQnameMap(), staxDriver.getOutputFactory().createXMLStreamWriter(strWriter), false, true);
			xstream.marshal(this, sw);
			sw.close();
			return strWriter.toString().replace("__", "_");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public String getRespCode() {
		return respCode;
	}

	public void setRespCode(String respCode) {
		this.respCode = respCode;
	}

	public String getMerchantId() {
		return merchantId;
	}

	public void setMerchantId(String merchantId) {
		this.merchantId = merchantId;
	}

	public String getSerailNo() {
		return serailNo;
	}

	public void setSerailNo(String serailNo) {
		this.serailNo = serailNo;
	}

	public String getBusiType() {
		return busiType;
	}

	public void setBusiType(String busiType) {
		this.busiType = busiType;
	}

	public Integer getTotalNumber() {
		return totalNumber;
	}

	public void setTotalNumber(Integer totalNumber) {
		this.totalNumber = totalNumber;
	}

	public List<ChargeWithdrawPlain.ChargeWithdrawResult> getResults() {
		return results;
	}

	public void setResults(List<ChargeWithdrawPlain.ChargeWithdrawResult> results) {
		this.results = results;
	}

	@XStreamAlias("result")
	public class ChargeWithdrawResult {
		@JSONField(serialize = false)
		@XStreamAlias("ext_tp")
		private String extType;
		@XStreamAlias("txn_date")
		private String date;
		@XStreamAlias("txn_time")
		private String time;
		@XStreamAlias("mchnt_ssn")
		private String busiId;
		@XStreamAlias("txn_amt")
		private String amount;
		@JSONField(serialize = false)
		@XStreamAlias("fuiou_acct_no")
		private String virtualAccountNo;
		@XStreamAlias("cust_no")
		private String accountNo;
		@XStreamAlias("artif_nm")
		private String accountName;
		@XStreamAlias("remark")
		private String remark;
		@JSONField(serialize = false)
		@XStreamAlias("txn_rsp_cd")
		private String txn_rsp_cd;
		@JSONField(serialize = false)
		@XStreamAlias("rsp_cd_desc")
		private String rsp_cd_desc;

		// 业务需要的订单号
		private String orderId;

		// 支付模块自己的异常码和信息
		private Integer rspCode;
		private String rspMsg;

		public String getOrderId() {
			return orderId;
		}

		public void setOrderId(String orderId) {
			this.orderId = orderId;
		}

		public String getExtType() {
			return extType;
		}

		public void setExtType(String extType) {
			this.extType = extType;
		}

		public String getDate() {
			return date;
		}

		public void setDate(String date) {
			this.date = date;
		}

		public String getTime() {
			return time;
		}

		public void setTime(String time) {
			this.time = time;
		}

		public String getBusiId() {
			return busiId;
		}

		public void setBusiId(String busiId) {
			this.busiId = busiId;
		}

		public String getAmount() {
			return amount;
		}

		public void setAmount(String amount) {
			this.amount = amount;
		}

		public String getVirtualAccountNo() {
			return virtualAccountNo;
		}

		public void setVirtualAccountNo(String virtualAccountNo) {
			this.virtualAccountNo = virtualAccountNo;
		}

		public String getAccountNo() {
			return accountNo;
		}

		public void setAccountNo(String accountNo) {
			this.accountNo = accountNo;
		}

		public String getAccountName() {
			return accountName;
		}

		public void setAccountName(String accountName) {
			this.accountName = accountName;
		}

		public String getRemark() {
			return remark;
		}

		public void setRemark(String remark) {
			this.remark = remark;
		}

		public String getTxn_rsp_cd() {
			return txn_rsp_cd;
		}

		public void setTxn_rsp_cd(String txn_rsp_cd) {
			this.txn_rsp_cd = txn_rsp_cd;
		}

		public String getRsp_cd_desc() {
			return rsp_cd_desc;
		}

		public void setRsp_cd_desc(String rsp_cd_desc) {
			this.rsp_cd_desc = rsp_cd_desc;
		}

		public Integer getRspCode() {
			return rspCode;
		}

		public void setRspCode(Integer rspCode) {
			this.rspCode = rspCode;
		}

		public String getRspMsg() {
			return rspMsg;
		}

		public void setRspMsg(String rspMsg) {
			this.rspMsg = rspMsg;
		}
	}
}